//Sunday, December 13 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class RevealTriangle
{
public:
	vector <string> calcTriangle(vector <string> questionMarkTriangle)
	{
		N = questionMarkTriangle.size();
		for(int i=N-2; i>=0; i--)
		{
			int idx = -1;
			for (int j=0; j<N-i; j++)
				if(questionMarkTriangle[i][j] != '?')
					idx = j;
			for(int j=idx-1; j>=0; j--)
				questionMarkTriangle[i][j] = getdigit(questionMarkTriangle[i][j+1], questionMarkTriangle[i+1][j]);
			for(int j=idx+1; j<N-i; j++)
				questionMarkTriangle[i][j] = getdigit(questionMarkTriangle[i][j-1], questionMarkTriangle[i+1][j-1]);
		}
		return questionMarkTriangle;
	}
	char getdigit(char a, char b)
	{
		int aa = a - '0';
		int bb = b - '0';
		for(int c=0; c<10; c++)
		{
			if((aa + c)%10 == bb)
				return '0'+c;
		}
		return '0';
	}
	int N;
};